#! /usr/bin/python

def generateSubSets(n):
    total = 2**(n+1) - 1
    full = []
    for i in range(1, 2**n):
        org = i
	subset = set()
	index = 1
	while(org > 0):
	     if org%2 != 0: subset.add(index)
	     org  /= 2
	     index += 1
	full.append(subset)

    qualifier = []
    for B in full:
        for C in full:
	    if B.isdisjoint(C):  
	       qualifier.append((B, C))

    return qualifier

allQua = []
for q in range(7, 13):
    allQua.append(generateSubSets(q))

def exam(ll):
    qualifier = allQua[len(ll) - 8]
    #print qualifier
    for (B, C) in qualifier:
	sb = 0
	sc = 0
	for i in B:
	    sb += ll[i]
	for i in C:
	    #print i
	    sc += ll[i]
	    
	if sb == sc: 
	   #print B, C, sb
	   return False
	if len(B) > len(C) and sb < sc: return False
    return True

print exam([0, 157,150,164,119,79,159,161,139,158])

f = open("sets.txt", "r")

ss = 0
for i in range(100):
    s = f.readline().split(',')
    ll = [0]
    for j in s:
	ll.append(int(j))
    print ll
    if exam(ll):
       ss += sum(ll)
       print ll

print ss
